﻿using D.Traceability.Domain;
using D.Traceability.ErrorCode;
using D.Traceability.Read.API.APPlicant.Command;
using D.Traceability.Read.API.APPlicant.Command.BreedCommand;
using D.Traceability.Read.API.APPlicant.Command.DeepCommand;
using D.Traceability.Read.API.APPlicant.Command.SlaughterCommand;
using D.Traceability.Read.API.APPlicant.Command.TestCommand;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace D.Traceability.Read.API.Controllers
{
    /// <summary>
    /// 溯源管理
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class TraceController : ControllerBase
    {
        private readonly IMediator mediator;

        public TraceController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        /// <summary>
        /// 显示溯源管理列表
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<APIPaing<SU_TraceabilityModel>> ListTracea([FromQuery]ListTraceaCommand request)
        {
            return await mediator.Send(request);
        }

        /// <summary>
        /// 获取图片通过 (生产批次号 traceaBatch  类型pTyper 是否删除 traceaIsDelete)
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<APIResult<List<SU_PictureModel>>> GetTest([FromQuery]GetTestCommand request)
        { 
            return await mediator.Send(request);
        }

        /// <summary>
        /// 获取养殖信息(通过 生产批次)
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpGet]
        public async Task<APIResult<List<SU_BreedModel>>> GetBreed([FromQuery]GetBreedCommand request)
        { 
            return await mediator.Send(request);
        }


        /// <summary>
        /// 获取保健信息(通过 生产批次)
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpGet]
        public async Task<APIResult<List<SU_ImmunityModel>>> GetImmunity([FromQuery]GetImmunityCommand request)
        { 
            return await mediator.Send(request);
        }

        /// <summary>
        /// 获取企业信息(通过 生产批次)
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpGet]
        public async Task<APIResult<List<SU_EnterpriseModel>>> GetEnterprise([FromQuery]GetEnterpriseCommand request )
        { 
            return await mediator.Send(request);
        }

        /// <summary>
        /// 获取屠宰信息(通过 生产批次)
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpGet]
        public async Task<APIResult<List<SU_SlaughterModel>>> GetSlaughter([FromQuery]GetSlaughterCommand request, CancellationToken cancellationToken)
        { 
            return await mediator.Send(request);
        }


        /// <summary>
        /// 获取深加工信息
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpGet]
        public async Task<APIResult<List<SU_DeepModel>>> GetDeep([FromQuery]GetDeepCommand request)
        { 
            return await mediator.Send(request);
        }

        /// <summary>
        /// 获取供应商数据
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpGet]
        public async Task<APIResult<List<SU_SupplierModel>>> GetSupplier([FromQuery]GetSupplierCommand request)
        { 
            return await mediator.Send(request);
        }

    }
}
